#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int MOD = 100000000;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
using vec3 = vector<vector<vector<int>>>;

int get(int s, int j)
{
	return (s >> j) & 1;
}

int set(int s, int j, int v)
{
	return v == 0 ? (s & (~(1 << j))) : (s | (1 << j));
}

int methods(vec2 &gird, int i, int j, int s, vec3 &dp)
{
	if (i == gird.size()) {
		return 1;
	}

	if (j == gird[0].size()) {
		return methods(gird, i + 1, 0, s, dp);
	}

	if (dp[i][j][s] != -1) {
		return dp[i][j][s];
	}

	int ans = methods(gird, i, j + 1, set(s, j, 0), dp);
	if (gird[i][j] == 1 && (j == 0 || get(s, j - 1) == 0) && get(s, j) == 0) {
		ans = (ans + methods(gird, i, j + 1, set(s, j, 1), dp)) % MOD;
	}

	return dp[i][j][s] = ans;
}

int way_dp(vec2 &gird)
{
	int n = gird.size();
	int m = gird[0].size();
	vec2 dp(m + 1, vec(1 << m, 0));
	fill(dp[m].begin(), dp[m].end(), 1);

        int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			for (int s = 0; s < (1 << m); s++) {
			        ans = dp[j + 1][set(s, j, 0)];
				if (gird[i][j] == 1 && (j == 0 || get(s, j - 1) == 0) && get(s, j) == 0) {
					ans = (ans + dp[j + 1][set(s, j, 1)]) % MOD;
				}
                                dp[j][s] = ans;
			}
		}
                ans = dp[0][0];
		dp[0].swap(dp[m]);
                //copy(dp[0].begin(), dp[0].end(), dp[m].begin());
	}
	return ans;
}

int main()
{
	int n, m;
	cin >> n >> m;
	vec2 gird(n, vec(m, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> gird[i][j];
		}
	}
	// vec3 dp(n, vec2(m, vec(1 << m, -1)));
	// cout << methods(gird, 0, 0, 0, dp) << endl;
	cout << way_dp(gird) << endl;
	return 0;
}